package com.hawk.eye.client.tracer;

import com.hawk.eye.client.toolkit.LogPropertyHolder;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.AllArgsConstructor;

/**
 * @className: FeignRequestInterceptor
 * @description: feign远程调用时在请求头中追加TraceId
 * @author: salad
 * @date: 2023/1/25
 **/
@AllArgsConstructor
public class FeignRequestInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate template) {
        template.header("tid", LogPropertyHolder.get("tid", "N/A"));
        template.header("entranceUri", LogPropertyHolder.get("entranceUri", "N/A"));
    }

}
